~~BOZZA~~

AN005 - How to use stepper motors

0.1 INTRODUCTION

This document describe how to use the H2C40 card for control of stepper motors with Qview software (device settings) and in terms of hardware (card features).

0.2 STEP/DIRECTION COMMAND

The following picture shows the block diagram of a conventional positioning system, or analog output:

QEM instrument implements the trajectory and loop position generator.

The generator of the trajectory (EANPOS or CAMMING or JOINT device of QMOVE and microQMOVE family) generate the position at each execution (sampling). This value is the position it should take the axis (èalso called “virtual profile”) at each sampling instant. Now, in the drive for stepper motors they represent the impulses that must be provided to move the motor of the steps that match the position. Because each pulse the motor performs a step (or half step or microstep depending on the drive or of its programming) the pulse rate determines the rate of motor displacement.

0.3 PROGRAMMING

The movement of stepper motors can be performed using all systems that are equipped with positioning device having as a output analog voltage (EANPOS, CAMMING3, JOINT) and there is a H2C40 card that implements the pitch/yaw output generation.

The device will be used as positioning for cases with the analog output done d the following notes:

- In the device declaration, on the configuration file, you must set the bidirectional counter input to X.X so that the posit parameter is the value of the virtual position.

- In the device declaration, on the configuration file, you must set the hardware address of the DAC componentof the analog output with the slot number and the keyword PULSE01 or PULSE02 (instead of an01, an02).

- Positioning devices that drive stepper motors work in open loop so you don't need to run the LOOPON command (even if you execute, has no effect on the output of control).

- The pulse parameter must be set to the number of steps per revolution of the motor If you are using a full step resolution. In the case of higher resolutions (created by microstepping drives) the pulse parameter must be set to the number of step/Rev of the motor multiplied for the resolution. For example, having a motor from 200 steps/Rev and a drive set at a resolution of 1/10 by step we will have to set the pulse parameter with value 2000.

- The measure parameter must be set to the value of units of measurement corresponding to one revolution of the motor.

- The maxvel parameter, unlike positioners with analog output where the setting value corresponds to the speed reached by the axis, expressed in units of measurement, when the analogue output is 10V, in the positioner with stepper motors this parameter defines the maximum speed to which you want to move the axis. This speed must be chosen according to the characteristics of the motor and the load, because the torque delivered by a stepper motor is highly dependent on the speed.

0.4 LIMITATIONS

0.4.1 Setting the maxvel parameter

The maxvel value it is also restrictive to the choice of the steering drive resolution (microsteps) since it determines the maximum frequency of pulse signal output. For example, having an application that has the following characteristics:

stepper motor 200 step/Rev

driver with resolution 1/20 od step

screw with step 2mm

max speed motor 2mt/min

The maximum speed corresponds to 1000 rpm so the output frequency must be (1000rpm*4000 pulse/Rev)/60 = 66666 Hz

You must then make sure that the driver Board is able to generate this frequency. Otherwise you have to lower the resolution or reduce the maximum speed; for example the H2C40 card can reach only 50KHz; we will have a maximum possible speed of 750 rpm or by lowering the resolution to 1/10 of step we can get up to 1500rpm.

To facilitate the calculation of the maxvel parameter starting from the maximum desired STEP output frequency, you can use the “CalMaxVel” subroutine of the example application “DEMO_L2CZ2”. N.B. This function can be use only with the unitvel = 1 parameter.

0.4.2 Velocitá

Per le particolarità firmware del generatore di impulsi e della discretizzazione dell'uscita, la velocità di movimento dell'asse è condizionata dal tempo di campionamento. Per quello che si è potuto vedere su un sistema con vite-madrevite (non è detto che sia esattamente la stessa cosa su un sistema con trasmissione di movimento con cinghia elastica) l'impostazione di velocità corrispondenti a frequenze di uscita del segnale impulsi non multiple della frequenza di campionamento può generare vibrazioni sull'asse. Ci troveremmo in questa condizione, ad esempio, se avessimo un device con tempo di campionamento di 2ms e volessimo posizionare ad una velocità alla quale corrisponde una frequenza di 10200Hz. Il sistema è in grado di generare solamente frequenze multiple della frequenza di campionamento che è 500Hz, perciò dovremmo impostare una velocità alla quale corrisponde una frequenza di 10000Hz o di 10500Hz. Che cosa succede quando posizioniamo proprio a 10200Hz? Avremo che, per 4 campionamenti la velocità sarà 10000Hz e un per un campionamento invece sarà 10500Hz, la velocità media risulterà 10200Hz ma è come se avessimo un “rumore” sovrapposto alla frequenza di 10000Hz che potrebbe far “vibrare” l'asse. Ove possibile, quindi, è consigliabile impostare valori di velocità che rispettino la regola sopracitata.

Per agevolare il calcolo delle velocitá che non hanno l'effetto del rumore sovrapposto, è possibile utilizzare la subroutine “CalVel” dell'applicativo di esempio “DEMO_L2CZ2”. Questa subroutine calcola un valore di velocitá approssimata per difetto rispetto ad un valore desiderato.

N.B la subroutine funzione solo con unitvel = 1 (Um/s)

N.B nel caso di errore la funzione calco outvel = -1. Sono possibili due errori: 1)unitvel = 0 2) è stato utilizzato un tempo di campionamento che non permette di generare una frequenza di valore finito per es: 3, 6, 7, 9msec, ecc

0.5 SCHEDA HARDWARE

La scheda L2CZ2 (release hardware 1) consente di pilotare nr. 2 azionamenti per motore passo passo. La frequenza massima dell'uscita STEP è pari a 50KHz. Le uscite sono di tipo NPN con corrente massima di 200mA.

I collegamenti della morsettiera sono:

NomeDescrizione
COMComune delle uscite STEP1, DIR1, STEP2, DIR2. Da collegare allo zero volt degli ingressi azionamento.
STEP1Uscite STEP-DIREZIONE per l'azionamento 1 (X.PULSE01)
DIR1
STEP2Uscite STEP-DIREZIONE per l'azionamento 2 (X.PULSE02)
DIR2

0.6 APPLICATIVO DI ESEMPIO

Di seguito un esempio che dichiara un device EANPOS e muove la posizione tra quota zero e 100.

0.6.1 Config

;---------------------------------------------
; Project           : TEST_H2C40
; Module Name       : CONFIG
; Author            : 
; Date              : 26/04/2007
; Time              : 16.16.56
; Description       : 
;---------------------------------------------
 
 
;---------------------------------------------
;  Constants Definition
;
;  ConstName  Value
;---------------------------------------------
CONST
TC_EANPOS		0005
 
 
;---------------------------------------------
;  GLOBAL Variables Definition
;
;  VarName    Type (F, B, W, L, S)
;---------------------------------------------
GLOBAL                
myvel 		L
 
; - Used in CalVel & CalMaxVel
invel		L
outvel		L
pulse		L
meas		L
tsample		W
unitvel		B  
decpt		B
outfrq		L
frqc		S
frqp		L
maxfrq		L
 
;---------------------------------------------
;  TIMER Variables Definition
;
;  TimerName
;---------------------------------------------               
TIMER
timer01
 
 
;---------------------------------------------
;  Bus Configuration
;
;  SlotNumber  CardName  Version
;  If not present write '.' in CardName and Version
;---------------------------------------------
BUS
1	992BF	20
2	.		.
3	L2CZ2	.
 
 
;---------------------------------------------
;  INTDEVICE Declaration
;---------------------------------------------
INTDEVICE
ep01	EANPOS		TC_EANPOS 	X.X		X.X		X	3.PULSE01

0.6.2 Module 1

;---------------------------------------------
; Project           : TEST_H2C40
; Module Name       : MODULE1
; Author            : 
; Date              : 26/04/2007
; Time              : 16.16.59
; Description       : 
;---------------------------------------------
 
	ep01:pulse = 4000
	ep01:measure = 100
	ep01:taccdec = 100
	ep01:minpos = -999999
	ep01:maxpos = 999999
	ep01:setpos = 200
	ep01:unitvel = 1 
 
;- Calculate maxvel for 50KHz step output
	maxfrq = 50000
	pulse = ep01:pulse
	meas = ep01:measure
	tsample = TC_EANPOS
	unitvel = ep01:unitvel
	decpt = ep01:decpt
	CALL CalMaxVel
	IF (NOT(outvel EQ -1)) ; check if an error occur
		ep01:maxvel = outvel
	ENDIF
 
	INIT ep01
	WAIT ep01:st_init
 
	myvel = ep01:maxvel/10
 
MAIN:                   
 
; Calculate setvel based on myvel value
	invel = myvel
	pulse = ep01:pulse
	meas = ep01:measure
	tsample = TC_EANPOS
	unitvel = ep01:unitvel
	decpt = ep01:decpt
	CALL CalVel
	IF (NOT(outvel EQ -1)) ; check if an error occur
		ep01:setvel = outvel
	ENDIF
 
    timer01 = 1000
    WAIT timer01
    ep01:setpos = 100 
    START ep01         
    WAIT ep01:st_still
 
    timer01 = 1000
    WAIT timer01
    ep01:setpos = 0
    START ep01         
    WAIT ep01:st_still
 
    WAIT 1
    JUMP MAIN  
 
 
 
 
;------------------    
; Calculate velocity for stepper motion
;
; Input: 
;	invel			L - desired velocity
;	pulse			L - pulse parameter
;	meas			L - measure parameter
;	tsample			W - device time sample
;	unitvel			B - unitvel parameter  
;	decpt			B - decpt parameter
;
; Output:
;	outfrq			L - step output for desired velocity
;	outvel			L - velocity calculated
;
; Local variables: 
;	frqc			S
;	frqp			L
;------------------
SUB CalVel
 
	IF ((NOT unitvel) OR (1000%tsample))
		outfrq = -1
		outvel = -1
	ELSE
		outfrq = (invel * pulse) / (meas * POW(10,decpt))
	    frqc = 1000.0/tsample
	    IF outfrq LE frqc
	    	outvel = invel
		ELSE
			frqp = outfrq / frqc
			frqc = frqp * frqc
			outvel = (frqc * meas * POW(10,decpt)) / pulse
		ENDIF
	ENDIF	    	
ENDSUB    
 
 
;------------------    
; Calculate max velocity for stepper motion card
;
; Input: 
;	maxfrq			L - max step output frequency 
;	pulse			L - pulse parameter
;	meas			L - measure parameter
;	tsample			W - device time sample
;	unitvel			B - unitvel parameter  
;	decpt			B - decpt parameter
;
; Output:
;	outvel			L - velocity calculated
;
; Local variables: 
;	frqc			S
;	frqp			L
;------------------
SUB CalMaxVel
 
	IF (NOT unitvel)
		outvel = -1
	ELSE
		outvel = (maxfrq * meas * POW(10,decpt)) / pulse
	ENDIF	    	
ENDSUB    
 
END